using System;
using System.Collections.Generic;
using System.Linq;

namespace Corelib.Entities
{
	[Table(Name = "dbo.Address")]
	public class Address
	{

		#region Private Data Members

		private int  _addressID;
		private int  _personID;
		private string  _addrress1;
		private string  _addrress2;
		private string  _addrress3;
		private string  _addrress4;
		private string  _postalCode;
		private string  _phoneNumber;
		private string  _country;
		private DateTime  _createDate;
		private DateTime  _modifyDate;

		#endregion

		#region Private "Static" Data Members

		private static readonly string[] _propertyNames = new string[] {
			"AddressID",
			"PersonID",
			"Addrress1",
			"Addrress2",
			"Addrress3",
			"Addrress4",
			"PostalCode",
			"PhoneNumber",
			"Country",
			"CreateDate",
			"ModifyDate",
		};

		#endregion

		#region Constants

		public const int 
			FieldAddressIDIdx = 0,
			FieldPersonIDIdx = 1,
			FieldAddrress1Idx = 2,
			FieldAddrress2Idx = 3,
			FieldAddrress3Idx = 4,
			FieldAddrress4Idx = 5,
			FieldPostalCodeIdx = 6,
			FieldPhoneNumberIdx = 7,
			FieldCountryIdx = 8,
			FieldCreateDateIdx = 9,
			FieldModifyDateIdx = 10;

		#endregion

		#region Private instance data members

		private FieldInfo[] _fieldInfo = new FieldInfo[]{
			new FieldInfo(FieldAddressIDIdx,FieldType.Primitive),
			new FieldInfo(FieldPersonIDIdx,FieldType.Primitive),
			new FieldInfo(FieldAddrress1Idx,FieldType.Primitive),
			new FieldInfo(FieldAddrress2Idx,FieldType.Primitive),
			new FieldInfo(FieldAddrress3Idx,FieldType.Primitive),
			new FieldInfo(FieldAddrress4Idx,FieldType.Primitive),
			new FieldInfo(FieldPostalCodeIdx,FieldType.Primitive),
			new FieldInfo(FieldPhoneNumberIdx,FieldType.Primitive),
			new FieldInfo(FieldCountryIdx,FieldType.Primitive),
			new FieldInfo(FieldCreateDateIdx,FieldType.Primitive),
			new FieldInfo(FieldModifyDateIdx,FieldType.Primitive),
		};

		#endregion

		#region Public Properties

		[Column(DBType = "int not null")]
		public int AddressID
		{
			get { return this.GetHelper(_fieldInfo, _propertyNames, FieldAddressIDIdx,  _addressID); }
			set {  _addressID = this.SetValueTypeHelper(_fieldInfo, FieldAddressIDIdx,  _addressID, value,  _addressID == value); }
		}

		[Column(DBType = "int not null")]
		public int PersonID
		{
			get { return this.GetHelper(_fieldInfo, _propertyNames, FieldPersonIDIdx,  _personID); }
			set {  _personID = this.SetValueTypeHelper(_fieldInfo, FieldPersonIDIdx,  _personID, value,  _personID == value); }
		}

		[Column(DBType = "nvarchar(40) null")]
		public string Addrress1
		{
			get { return this.GetHelper(_fieldInfo, _propertyNames, FieldAddrress1Idx,  _addrress1); }
			set {  _addrress1 = this.SetValueTypeHelper(_fieldInfo, FieldAddrress1Idx,  _addrress1, value,  _addrress1 == value); }
		}

		[Column(DBType = "nvarchar(30) null")]
		public string Addrress2
		{
			get { return this.GetHelper(_fieldInfo, _propertyNames, FieldAddrress2Idx,  _addrress2); }
			set {  _addrress2 = this.SetValueTypeHelper(_fieldInfo, FieldAddrress2Idx,  _addrress2, value,  _addrress2 == value); }
		}

		[Column(DBType = "nvarchar(30) null")]
		public string Addrress3
		{
			get { return this.GetHelper(_fieldInfo, _propertyNames, FieldAddrress3Idx,  _addrress3); }
			set {  _addrress3 = this.SetValueTypeHelper(_fieldInfo, FieldAddrress3Idx,  _addrress3, value,  _addrress3 == value); }
		}

		[Column(DBType = "nvarchar(30) null")]
		public string Addrress4
		{
			get { return this.GetHelper(_fieldInfo, _propertyNames, FieldAddrress4Idx,  _addrress4); }
			set {  _addrress4 = this.SetValueTypeHelper(_fieldInfo, FieldAddrress4Idx,  _addrress4, value,  _addrress4 == value); }
		}

		[Column(DBType = "nvarchar(30) null")]
		public string PostalCode
		{
			get { return this.GetHelper(_fieldInfo, _propertyNames, FieldPostalCodeIdx,  _postalCode); }
			set {  _postalCode = this.SetValueTypeHelper(_fieldInfo, FieldPostalCodeIdx,  _postalCode, value,  _postalCode == value); }
		}

		[Column(DBType = "nvarchar(50) null")]
		public string PhoneNumber
		{
			get { return this.GetHelper(_fieldInfo, _propertyNames, FieldPhoneNumberIdx,  _phoneNumber); }
			set {  _phoneNumber = this.SetValueTypeHelper(_fieldInfo, FieldPhoneNumberIdx,  _phoneNumber, value,  _phoneNumber == value); }
		}

		[Column(DBType = "nvarchar(50) null")]
		public string Country
		{
			get { return this.GetHelper(_fieldInfo, _propertyNames, FieldCountryIdx,  _country); }
			set {  _country = this.SetValueTypeHelper(_fieldInfo, FieldCountryIdx,  _country, value,  _country == value); }
		}

		[Column(DBType = "datetime not null")]
		public DateTime CreateDate
		{
			get { return this.GetHelper(_fieldInfo, _propertyNames, FieldCreateDateIdx,  _createDate); }
			set {  _createDate = this.SetValueTypeHelper(_fieldInfo, FieldCreateDateIdx,  _createDate, value,  _createDate == value); }
		}

		[Column(DBType = "datetime null")]
		public DateTime ModifyDate
		{
			get { return this.GetHelper(_fieldInfo, _propertyNames, FieldModifyDateIdx,  _modifyDate); }
			set {  _modifyDate = this.SetValueTypeHelper(_fieldInfo, FieldModifyDateIdx,  _modifyDate, value,  _modifyDate == value); }
		}

		#endregion
	}
}
